home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 2 / 002.d81 / loan planner (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1984-01-01  |  4.9 KB  |  170 lines

  1. 10 rem (NULL)oan (NULL)lanner by peekaldwin (NULL). (NULL)routman
  2. 20 rem (NULL)ranslated for the lenommodore 64 by str$onna (NULL). (NULL)oody
  3. 30 :
  4. 40 poke53272,23:rem selects upper/lower case
  5. 50 printchr$(8):rem disables c/shift key
  6. 60 poke53280,11:rem sets border color to gray 1
  7. 70 poke53281,11:rem set background color to gray 1
  8. 80 printchr$(158):rem set character color to yellow
  9. 90 :
  10. 100 rem set up title page
  11. 110 :
  12. 120 print chr$(147):rem clear/home screen
  13. 130 print tab(13)"[204][207][193][206][160][208][204][193][206][206][197][210]":print""
  14. 140 print tab(18)"by":print""
  15. 150 print tab(10)"[194]aldwin [204]. [212]routman"
  16. 160 printtab(6)"[212]ranslated by [196]onna [203]. [215]oody"
  17. 170 printtab(7) " [208]ress any key to continue";
  18. 180 printtab(35):poke204,0:poke207,0:geta$:poke204,1
  19. 190 ifa$=""then180
  20. 200 :
  21. 210 rem instructions and choice screen
  22. 220 :
  23. 230 printchr$(147):print"[198]ive main variables recur in finance"
  24. 240 print"problems.  [212]hese are:"
  25. 250 print:printtab(5)"[193]nnual interest rate":printtab(5)"[208]resent value of loan"
  26. 260 printtab(5)"[198]uture value of loan":printtab(5)"[205]onthly payment"
  27. 270 printtab(5)"[206]umber of payments"
  28. 280 print:print"[212]his program will permit you to calcu-"
  29. 290 print"late one of the following, given the    others."
  30. 300 print:print"[215]hich do you want to calculate?"
  31. 310 printtab(5)"1.  [205]onthly [208]ayment"
  32. 320 printtab(5)"2.  [193]mount you can [194]orrow":printtab(5)"3.  [206]umber of [208]ayments"
  33. 330 printtab(5)"4.  [194]alance after [206] [208]ayments":printtab(5)"5.  [193]ccumulated [201]nterest"
  34. 340 printtab(9)"(payments [202] thru [203])"
  35. 350 print:print"[197]nter <1 - 5>: ";
  36. 360 poke204,0:poke207,0: geta$:ifa$=""then360
  37. 370 a=val(a$):poke204,1
  38. 380 ifa<1ora>5thenprint:goto440
  39. 390 printchr$(147)
  40. 400 print:print:print"[197]nter the annual interest rate in per-"
  41. 410 poke19,32: input"cent: ";r$:r=val(r$):print
  42. 420 ifr<=0thenzz=3:zy=0:gosub1460:goto400
  43. 430 i=(r/12)/100:onagoto480,530,640,700,770
  44. 440 zz=20:zy=18:gosub1460:goto350
  45. 450 :
  46. 460 rem  monthly payment information
  47. 470 :
  48. 480 gosub920:gosub 950:gosub860:ific=0goto1500
  49. 490 mp=pv*(i/(1-ic)):gosub870:j=1:k=np:ijk=mp*np-pv:goto1090
  50. 500 :
  51. 510 rem  amount to borrow information
  52. 520 :
  53. 530 print:print"[197]nter the amount you want to pay per"
  54. 540 input"month: ";mp$:mp=val(mp$):print
  55. 550 ifmp<=0thenzz=6:zy=4:gosub1460:goto530
  56. 560 print:print"[197]nter the number of payments you want"
  57. 570 input"to make: ";np$:np=val(np$):print
  58. 580 ifnp<=0thenzz=9:zy=7:gosub1460:goto560
  59. 590 np=int(np)
  60. 600 gosub860:ific=0then1500
  61. 605 pv=mp*(1-ic)/i:gosub870:j=1:k=np:ijk=mp*np-pv:goto1090
  62. 610 :
  63. 620 rem  number of payments information
  64. 630 :
  65. 640 gosub920:gosub980
  66. 645 t=i*pv/mp:ift>1then1500
  67. 650 np=-(log(1-t))/log(1+i):gosub860:ific=0then1500
  68. 655 gosub870
  69. 660 j=1:k=int(np):ijk=mp*np-pv:goto1090
  70. 670 :
  71. 680 rem  balance information
  72. 690 :
  73. 700 gosub920:gosub980
  74. 710 print:print"[194]alance after how many payments?"
  75. 720 inputnp$:np=val(np$):print:ifnp<=0thenzz=12:zy=10:gosub1460:goto710
  76. 730 gosub860:ific=0then1500
  77. 735 gosub870:j=1:k=np:goto810
  78. 740 :
  79. 750 rem accumulated interest information
  80. 760 :
  81. 770 gosub920:gosub980:gosub1010
  82. 780 :
  83. 790 rem calculations
  84. 800 :
  85. 810 np=j-1:gosub860:ific=0then1500
  86. 812 gosub870:bj=rb:np=k:gosub860:ific=0then1500
  87. 815 gosub870:bk=rb
  88. 820 gosub880:goto1090
  89. 830 :
  90. 840 rem calculations
  91. 850 :
  92. 860 ic=(1+i)^-np:return
  93. 870 rb=(1/ic)*(mp*((ic-1)/i)+pv):return
  94. 880 ijk=bk-bj+(k-j+1)*mp:return
  95. 890 :
  96. 900 rem input lines
  97. 910 :
  98. 920 print:print  "[197]nter initial amount of your loan:":inputpv$:pv=val(pv$):print
  99. 930 ifpv<=0thenzz= 6:zy= 4:gosub1460:goto920
  100. 940 return
  101. 950 print:print"[197]nter number of monthly payments:":inputnp$:np=val(np$):print
  102. 960 ifnp<=0thenzz= 9:zy=7:gosub1460:goto950
  103. 970 np=int(np):return
  104. 980 print:print"[197]nter your monthly payment: ":inputmp$:mp=val(mp$):print
  105. 990 ifmp<=0thenzz=9:zy=7:gosub1460:goto980
  106. 1000 return
  107. 1010 print:print"[197]nter payment number where calculations":input"are to begin: ";j$
  108. 1020 j=val(j$):print:ifj<=0thenzz=12:zy=10:gosub1460:goto1010
  109. 1030 print:print"[197]nter payment number where calculations":input"are to end: ";k$
  110. 1040 k=val(k$):print:ifk<=0thenzz=15:zy=13:gosub1460:goto1030
  111. 1050 return
  112. 1060 :
  113. 1070 rem  print out information
  114. 1080 :
  115. 1090 printchr$(147):print"[217]our loan calculations are:":print
  116. 1100 print"[193]nnual interest:";:x=r:gosub1320:print" "x2$"%"
  117. 1110 print"[193]mount of loan:";:x=pv:gosub1320:print"$"x2$
  118. 1120 print"[205]onthly payment:";:x=mp:gosub1320:print"$"x2$
  119. 1130 print"[206]umber of payments:";:x=np:gosub1320:print"[160]"x2$
  120. 1140 print"[212]otal amount paid:";:x=mp*np:gosub1320:print"$"x2$
  121. 1150 print"[201]nterest paid:";:x=ijk:gosub1320:print"$"x2$
  122. 1160 print"(payments ";j;" thru ";k;")"
  123. 1170 print"[210]emaining balance:";:x=rb:gosub1320:print"$"x2$
  124. 1180 print"(after ";k;" payments)"
  125. 1190 :
  126. 1200 rem  another or end
  127. 1210 :
  128. 1220 print:print"[196]o another calculation (y/n)?[160]";
  129. 1230 poke204,0:poke207,0:getn$:poke204,1:ifn$=""then1230
  130. 1250 ifn$="y"thenprintchr$(147):goto300
  131. 1260 ifn$="n"then1290
  132. 1270 ifn$<>"n"orn$<>"y"thenprint:zz=15:zy=14: gosub1460:goto1220
  133. 1280 :
  134. 1290 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
  135. 1295 poke631,13:poke632,13:poke198,2:end
  136. 1300 :
  137. 1310 rem  formats numbers for print out
  138. 1320 x=int((x+.001)*100):xx$=str$(x):x%=len(xx$)
  139. 1330 xo$=right$(xx$,2):rem xo$ is decimal part of the number
  140. 1340 x1$="":rem x1$ is integer part of the number
  141. 1350 ifx=0thenx1$="0":xo$="00":goto1400
  142. 1360 ifx%=1thenx1$="0"+xo$:goto1400
  143. 1370 ifx%=2thenifleft$(xx$,1)="-"thenxo$="0"+right$(xo$,1):x1$="-0":goto1400
  144. 1380 ifx%=2then1400
  145. 1390 x1$=left$(xx$,(x%-2))
  146. 1400 x2$=x1$+"."+xo$:ht=len(x1$)
  147. 1410 rem x2$  is formatted number.
  148. 1420 printtab(29-ht):return
  149. 1430 :
  150. 1440 rem error trapping response
  151. 1450 :
  152. 1460 forxz=1to20-zz:print"";:next
  153. 1470 print"[211]orry.  [217]ou made an incorrect entry.    [208]lease re-enter."
  154. 1480 forxz=1to23-zy:print"[145]";:next
  155. 1490 return
  156. 1492 :
  157. 1495 rem error message if ic=0 to prevent division by zero
  158. 1499 :
  159. 1500 printchr$(147)
  160. 1501 poke53280,1:poke53281,2:printchr$(5)
  161. 1510 print"[212]here has been an error."
  162. 1520 print:print"[207]ne of the enteries you made resulted"
  163. 1525 print"in a mathematical error."
  164. 1530 print:print"[208]lease re-check your numbers."
  165. 1540 printtab(7)" [208]ress any key to continue";
  166. 1550 print tab(35):poke204,0:poke207,0:geta$
  167. 1560 ifa$=""then1550
  168. 1570 poke204,1
  169. 1580 poke53280,11:poke53281,11:printchr$(158):printchr$(147):goto300
  170.